<h2>DESCRIPTION</h2>

<em>v.rast.stats</em> calculates basic univariate statistics from
a raster map only for the parts covered by the specified vector map.
The vector map will be rasterized according to the raster map resolution.
Then univariate statistics are calculated per vector category (cat) from
the raster map and the results uploaded to the vector map attribute table.
A new column is generated in the attribute table for each statistic requested
in <b>method</b> (if not already present).
<p>
The univariate statistics include the number of raster cells counted,
the number of raster NULL cells counted, minimum
and maximum cell values, range, average, <!-- r.univar: arithmetic mean -->
standard deviation, variance, coefficient of variation, sum, first quartile,
median, third quartile, and percentile.

<h2>NOTES</h2>
<em>v.rast.stats</em> is only meaningful for lines or polygons.
<p>
The module may take a long time to run if the raster region contains a large
number of cells. In this case the <b>--verbose</b> flag may be used to track
progress.
<p>The script stops if a (prefixed) upload column is already present in the
vector map attribute table, unless otherwise instructed with the <b>-c</b>
continue flag. The column prefix will be separated from the statistic name
with an underscore. For example with a prefix of "<tt>elev</tt>" the sum
column will be named <tt>elev_sum</tt>.
<p>If a DBF database is being used, note that column names are restricted by the
DBF specification to 10 characters. Therefore it is advised to be economical
in the use of the column prefix when using DBF as any additional characters
will be chopped off.
<p>If a MASK is present, it will be restored after the script finished.
The script changes temporarily to the resolution of the given raster map.
<p><!-- r.univar limitation -->
Large amounts of system memory can be used when extended statistics
(<em>first_quartile,median,third_quartile,percentile </em>) are being requested
with a very large region setting. If the region is too large the module
should display memory allocation errors. Basic statistics can be calculated
using any size input region.

<h2>EXAMPLES</h2>

Example to upload DEM statistics to ZIP codes vector map
(North Carolina sample dataset):

<div class="code"><pre>
g.copy vect=zipcodes_wake,myzipcodes_wake
# set computational region to DEM:
g.region raster=elevation -p
# calculate selected DEM statistics, upload to vector map table:
v.rast.stats myzipcodes_wake raster=elevation \
  column_prefix=elev method=minimum,maximum,average,range,stddev,percentile \
  percentile=95
# verify results:
v.info -c myzipcodes_wake
v.db.select myzipcodes_wake
v.univar myzipcodes_wake column=elev_range type=centroid
</pre></div>

<h2>SEE ALSO</h2>

<em>
<a href="r.univar.html">r.univar</a>,
<a href="v.univar.html">v.univar</a>,
<a href="v.vect.stats.html">v.vect.stats</a>,
<a href="v.what.rast.html">v.what.rast</a>,
<a href="v.what.rast3.html">v.what.rast3</a>,
<a href="v.what.vect.html">v.what.vect</a>
</em>

<h2>AUTHOR</h2>

Markus Neteler, CEA (for the <a href="http://www.eden-fp6project.net/">EDEN EU/FP6 Project</a>)

<!--
<p>
<i>Last changed: $Date$</i>
-->
